﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Messaging;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using Toolbox;

namespace FremtidensPlejehjem_Server.Messaging
{
    public class Producer
    {
        MessageQueue _channel;

        public Producer(MessageQueue channel)
        {
            _channel = channel;
        }

        public void SendMessage(object message, string messageLabel)
        {
            Console.WriteLine("Sending reply to " + _channel.QueueName);

            string xmlMessage = GeneralTools.SerializeMessage(message);
            Message msg = new Message();
            msg.Body = xmlMessage;
            msg.Label = messageLabel;

            _channel.Send(msg);

            Console.WriteLine("Reply has been sent");
        }
    }
}
